#ifndef CLIENT_H
#define CLIENT_H

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <termios.h>
#include <time.h>
#include <libgen.h>
#include <linux/limits.h>

// 网络配置
#define SERVER_IP "192.168.150.131"
#define SERVER_PORT 8080
#define BUFFER_SIZE 4096

// 终端控制宏
#define CLEAR_SCREEN "\033[2J\033[H"
#define BLACK_BG "\033[40m"
#define WHITE_TEXT "\033[37m"
#define GREEN_TEXT "\033[32m"
#define RED_TEXT "\033[31m"
#define YELLOW_TEXT "\033[33m"
#define BLUE_TEXT "\033[34m"
#define RESET_TEXT "\033[0m"

// 全局状态声明
extern int logged_in;
extern char current_username[50];
extern int current_directory_id;

// 函数声明
int connect_to_server(void);
void send_command(int sockfd, const char *command);
void receive_response(int sockfd);
void interactive_main_menu(int sockfd);
void get_password_input(char *buffer, size_t size);
void press_enter_to_continue(void);
void handle_register(int sockfd);
int handle_login(int sockfd);
void handle_file_upload(int sockfd);
void handle_file_download(int sockfd);
void handle_file_list(int sockfd);
void handle_file_delete(int sockfd);
void handle_mkdir(int sockfd);
void handle_logout(int sockfd);
void change_directory(int sockfd);

#endif // CLIENT_H